package com.wokeMy.view.channe.mobao;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.woke.MybankblindActivity;
import com.woke.data.Data_bindcarlist;
import com.woke.data.UnionPayChannel;
import com.woke.method.MyApp;
import com.wokeMy.view.base.BaseActivity;
import com.wokeMy.view.model.Constant;
import com.zhongcai.online.R;

public class MobaoczActivity extends BaseActivity implements View.OnClickListener {

    TextView money_mbseletcard_tv,zfcard_mbseletcard;
    RelativeLayout zhifu_mbselectcard_rl;
    ImageView back;
    Button paybt;

    Data_bindcarlist listdata;
    Intent intent;
    float money;
    int way_id,vip_level;
    String user_id;
    String pay_card_no,card_no;
    UnionPayChannel unionPayChannel;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_mobaocz);
    }

    @Override
    public void initActivity() {
        zhifu_mbselectcard_rl.setOnClickListener(this);
        back.setOnClickListener(this);
        paybt.setOnClickListener(this);
        money_mbseletcard_tv.setText("￥"+money);
    }

    @Override
    public void initView() {
        money_mbseletcard_tv = myFindViewById(R.id.money_mbseletcard_tv);
        zhifu_mbselectcard_rl = myFindViewById(R.id.zhifu_mbselectcard_rl);
        zfcard_mbseletcard = myFindViewById(R.id.zfcard_mbseletcard);
        back = myFindViewById(R.id.back_mbselectc_iv);
        paybt = myFindViewById(R.id.pay_mbselectc_bt);
    }

    @Override
    public void initData() {
        intent=getIntent();
        money = intent.getFloatExtra ("money", 0.01f);
        way_id = intent.getIntExtra ("way_id", 0);
        Log.e("initData",money+"////"+way_id);
        //        user_id = intent.getStringExtra("user_id");
        user_id=((MyApp)getApplication()).getDatas_load().getId();
        vip_level=(Integer.parseInt(((MyApp)getApplication()).getDatas_load().getUser_type()));
        //        unionPayChannel=(UnionPayChannel)intent.getSerializableExtra("unionPayChanne");
        //        Log.e("initData",money+" "+unionPayChannel.getId()+" "+unionPayChannel.get)
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.money_mbseletcard_tv:
                break;
            case R.id.back_mbselectc_iv:
                finish();
                break;
            case R.id.pay_mbselectc_bt:
                if (pay_card_no==null||pay_card_no.equals("")){
                    Toast.makeText(MobaoczActivity.this,"付款卡未选择",Toast.LENGTH_SHORT).show();
                }else {
                    Intent intent=new Intent(MobaoczActivity.this,MobaokjczActivity.class);
                    intent.putExtra("listdata",listdata);
                    intent.putExtra ("money",money);
                    intent.putExtra ("way_id",way_id);
                    startActivity(intent);
                }
                //                Toast.makeText(MobaoczActivity.this,"暂未开通",Toast.LENGTH_SHORT).show();
                break;
            case R.id.zhifu_mbselectcard_rl:
                Intent intent = new Intent (MobaoczActivity.this, MybankblindActivity.class);
                intent.putExtra ("czhiortxian", "mobaoAll");
                startActivityForResult (intent, Constant.REQUEST_ZHIFU);
                break;
            default:
                break;
        }
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //        Log.e("RESPONSE_JIESHUAN",resultCode+"");
        if (resultCode==Constant.RESPONSE_ZHIFU){
            listdata=(Data_bindcarlist)data.getSerializableExtra("listdata");
            pay_card_no=listdata.cardno;
            zfcard_mbseletcard.setText(pay_card_no.substring(0, 4)+"    "+"***"+"    "+"***"+"    "+"***"+"    "+pay_card_no.substring(pay_card_no.length()-3,pay_card_no.length()));
        }
    }

}
